Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Functions
cmdutil.h File Reference
#include "cmdvar.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double PointToValue (double Val)
 Convert a value in points to a value in the current document units.
double ValueToPoint (double Val)
 Convert a value in the current document units to a value in points.
double pageUnitXToDocX (double pageUnitX)
 Convert an X co-ordinate part in page units to a document co-ordinate in system units.
double docUnitXToPageX (double pageUnitX)
 Doc units -> page-relative units.
double pageUnitYToDocY (double pageUnitY)
 Convert a Y co-ordinate part in page units to a document co-ordinate in system units.
double docUnitYToPageY (double pageUnitY)
 Doc units -> page-relative units.
int GetItem (QString Name)
void ReplaceColor (QString col, QString rep)
PageItem * GetUniqueItem (QString name)
 Returns named PageItem, or selection if name '', or exception and NULL if no item.
PageItem * getPageItemByName (QString name)
 Returns named PageItem, or exception and NULL if not found.
bool checkHaveDocument ()
 Checks to see if there is a document open.
bool ItemExists (QString name)
 Checks to see if a pageItem named 'name' exists and return true if it does exist.
QStringList getSelectedItemsByName ()
 Returns a list of the names of all selected PageItems.
bool setSelectedItemsByName (QStringList &itemNames)
 Replaces the current selection by selecting all the items named in the passed QStringList.

Function Documentation

Checks to see if there is a document open.

If there is an open document, returns true. If there is no open document, sets a Python exception and returns false. 2004-10-27 Craig Ringer

Definition at line 192 of file cmdutil.cpp.

{
    if (ScCore->primaryMainWindow()->HaveDoc)
        return true;
    // Caller is required to check for false return from this function
    // and return NULL.
    PyErr_SetString(NoDocOpenError, QString("Command does not make sense without an open document"));
    return false;
}

Here is the call graph for this function:

double docUnitXToPageX ( double  pageUnitX)

Doc units -> page-relative units.

Definition at line 36 of file cmdutil.cpp.

{
       return PointToValue(pageUnitX - ScCore->primaryMainWindow()->doc->currentPage()->xOffset());
}

Here is the call graph for this function:

Here is the caller graph for this function:

double docUnitYToPageY ( double  pageUnitY)

Doc units -> page-relative units.

Definition at line 50 of file cmdutil.cpp.

{
       return PointToValue(pageUnitY - ScCore->primaryMainWindow()->doc->currentPage()->yOffset());
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GetItem ( QString  Name)

Definition at line 55 of file cmdutil.cpp.

{
       if (!Name.isEmpty())
       {
              for (uint a = 0; a < ScCore->primaryMainWindow()->doc->Items->count(); a++)
              {
                     if (ScCore->primaryMainWindow()->doc->Items->at(a)->itemName() == Name)
                            return static_cast<int>(a);
              }
       }
       else
       {
              if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0)
                     return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0)->ItemNr;
       }
       return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PageItem* getPageItemByName ( QString  name)

Returns named PageItem, or exception and NULL if not found.

Author:
03/10/2004 Petr Vanek
05/02/02 Craig Ringer

Definition at line 151 of file cmdutil.cpp.

{
       if (name.length() == 0)
       {
              PyErr_SetString(PyExc_ValueError, QString("Cannot accept empty name for pageitem"));
              return NULL;
       }
       for (uint j = 0; j<ScCore->primaryMainWindow()->doc->Items->count(); j++)
       {
              if (name==ScCore->primaryMainWindow()->doc->Items->at(j)->itemName())
                     return ScCore->primaryMainWindow()->doc->Items->at(j);
       } // for items
       PyErr_SetString(NoValidObjectError, QString("Object not found"));
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QStringList getSelectedItemsByName ( )

Returns a list of the names of all selected PageItems.

Definition at line 202 of file cmdutil.cpp.

{
       /*
       QStringList names;
       QPtrListIterator<PageItem> it(ScCore->primaryMainWindow()->view->SelItem);
       for ( ; it.current() != 0 ; ++it)
              names.append(it.current()->itemName());
       return names;
       */
       return ScCore->primaryMainWindow()->doc->m_Selection->getSelectedItemsByName();
}

Here is the call graph for this function:

Here is the caller graph for this function:

PageItem* GetUniqueItem ( QString  name)

Returns named PageItem, or selection if name '', or exception and NULL if no item.

Returns a pointer to a PageItem by looking it up by name - page independent. If `name' is empty, returns selected item. If the named item is not found, or `name' is empty and no item is selected, sets an exception and returns NULL.

Author:
03/10/2004 petr vanek
05/02/02 Craig Ringer

Definition at line 137 of file cmdutil.cpp.

{
       if (name.length()==0)
              if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0)
                     return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0);
              else
              {
                     PyErr_SetString(NoValidObjectError, QString("Cannot use empty string for object name when there is no selection"));
                     return NULL;
              }
       else
              return getPageItemByName(name);
}

Here is the call graph for this function:

bool ItemExists ( QString  name)

Checks to see if a pageItem named 'name' exists and return true if it does exist.

Returns false if there is no such object, or if the empty string ("") is passed.

Definition at line 173 of file cmdutil.cpp.

{
       if (name.length() == 0)
              return false;
       for (uint j = 0; j<ScCore->primaryMainWindow()->doc->Items->count(); j++)
       {
              if (name==ScCore->primaryMainWindow()->doc->Items->at(j)->itemName())
                     return true;
       } // for items
       return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double pageUnitXToDocX ( double  pageUnitX)

Convert an X co-ordinate part in page units to a document co-ordinate in system units.

Definition at line 30 of file cmdutil.cpp.

{
       return ValueToPoint(pageUnitX) + ScCore->primaryMainWindow()->doc->currentPage()->xOffset();
}

Here is the call graph for this function:

Here is the caller graph for this function:

double pageUnitYToDocY ( double  pageUnitY)

Convert a Y co-ordinate part in page units to a document co-ordinate in system units.

The document co-ordinates have their origin somewere up and left of the first page, where page co-ordinates have their origin on the top left of the current page.

Definition at line 45 of file cmdutil.cpp.

{
       return ValueToPoint(pageUnitY) + ScCore->primaryMainWindow()->doc->currentPage()->yOffset();
}

Here is the call graph for this function:

Here is the caller graph for this function:

double PointToValue ( double  Val)

Convert a value in points to a value in the current document units.

Definition at line 17 of file cmdutil.cpp.

{
       return pts2value(Val, ScCore->primaryMainWindow()->doc->unitIndex());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ReplaceColor ( QString  col,
QString  rep 
)

Definition at line 73 of file cmdutil.cpp.

{
       QColor tmpc;
       for (uint c = 0; c < ScCore->primaryMainWindow()->doc->Items->count(); c++)
       {
              PageItem *ite = ScCore->primaryMainWindow()->doc->Items->at(c);
              if (ite->itemType() == PageItem::TextFrame)
              {
                     for (int d = 0; d < ite->itemText.length(); d++)
                     {
                            //FIXME:NLS  that should work on runs
                            if (col == ite->itemText.charStyle(d).fillColor())
                                   ite->itemText.item(d)->setFillColor(rep);
                            if (col == ite->itemText.charStyle(d).strokeColor())
                                   ite->itemText.item(d)->setStrokeColor(rep);
                     }
              }
              if (col == ite->fillColor())
                     ite->setFillColor(rep);
              if (col == ite->lineColor())
                     ite->setLineColor(rep);
              QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
              for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
              {
                     if (col == cstops.at(cst)->name)
                     {
                            ite->SetFarbe(&tmpc, rep, cstops.at(cst)->shade);
                            cstops.at(cst)->color = tmpc;
                            cstops.at(cst)->name = rep;
                     }
              }
       }
       for (uint c = 0; c < ScCore->primaryMainWindow()->doc->MasterItems.count(); c++)
       {
              PageItem *ite = ScCore->primaryMainWindow()->doc->MasterItems.at(c);
              if (ite->itemType() == PageItem::TextFrame)
              {
                     for (int d = 0; d < ite->itemText.length(); d++)
                     {
                            //FIXME: NLS this should work on runs
                            if (col == ite->itemText.charStyle(d).fillColor())
                                   ite->itemText.item(d)->setFillColor(rep);
                            if (col == ite->itemText.charStyle(d).strokeColor())
                                   ite->itemText.item(d)->setStrokeColor(rep);
                     }
              }
              if (col == ite->fillColor())
                     ite->setFillColor(rep);
              if (col == ite->lineColor())
                     ite->setLineColor(rep);
              QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
              for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
              {
                     if (col == cstops.at(cst)->name)
                     {
                            ite->SetFarbe(&tmpc, rep, cstops.at(cst)->shade);
                            cstops.at(cst)->color = tmpc;
                            cstops.at(cst)->name = rep;
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool setSelectedItemsByName ( QStringList &  itemNames)

Replaces the current selection by selecting all the items named in the passed QStringList.

Returns false if one or more items can't be selected, true if all were selected. Selection state is undefined on failure.

Definition at line 214 of file cmdutil.cpp.

{
       ScCore->primaryMainWindow()->view->Deselect();
       // For each named item
       for (QStringList::Iterator it = itemNames.begin() ; it != itemNames.end() ; it++)
       {
              // Search for the named item
              PageItem* item = 0;
              for (uint j = 0; j < ScCore->primaryMainWindow()->doc->Items->count(); j++)
                     if (*it == ScCore->primaryMainWindow()->doc->Items->at(j)->itemName())
                            item = ScCore->primaryMainWindow()->doc->Items->at(j);
              if (!item)
                     return false;
              // and select it
              ScCore->primaryMainWindow()->view->SelectItemNr(item->ItemNr);
       }
       return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

double ValueToPoint ( double  Val)

Convert a value in the current document units to a value in points.

Definition at line 23 of file cmdutil.cpp.

{
       return value2pts(Val, ScCore->primaryMainWindow()->doc->unitIndex());
}

Here is the call graph for this function:

Here is the caller graph for this function: