LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/starmath/source - ElementsDockingWindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 144 240 60.0 %
Date: 2013-07-09 Functions: 26 34 76.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <ElementsDockingWindow.hxx>
      21             : 
      22             : #include <starmath.hrc>
      23             : #include <smmod.hxx>
      24             : #include <config.hxx>
      25             : #include <view.hxx>
      26             : #include <visitors.hxx>
      27             : 
      28             : #include <svl/stritem.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : 
      31             : SV_DECL_REF(SmDocShell)
      32             : SV_IMPL_REF(SmDocShell)
      33             : 
      34         340 : SmElement::SmElement(SmNodePointer pNode, OUString aText) :
      35             :     mpNode(pNode),
      36         340 :     maText(aText)
      37         340 : {}
      38             : 
      39         646 : SmElement::~SmElement()
      40         646 : {}
      41             : 
      42         702 : SmNodePointer SmElement::getNode()
      43             : {
      44         702 :     return mpNode;
      45             : }
      46             : 
      47          34 : SmElementSeparator::SmElementSeparator() :
      48          34 :     SmElement(SmNodePointer(), OUString())
      49          34 : {}
      50             : 
      51             : //////////////////////////////////
      52             : 
      53             : const sal_uInt16 SmElementsControl::aUnaryBinaryOperatorsList[] =
      54             : {
      55             :     RID_PLUSX, RID_MINUSX, RID_PLUSMINUSX, RID_MINUSPLUSX,
      56             :     0xFFFF,
      57             :     RID_XPLUSY, RID_XMINUSY, RID_XCDOTY, RID_XTIMESY,
      58             :     RID_XSYMTIMESY, RID_XOVERY,  RID_XDIVY, RID_XSYMDIVIDEY,
      59             :     RID_XCIRCY, RID_XWIDESLASHY, RID_XWIDEBSLASHY,
      60             :     0xFFFF,
      61             :     RID_NEGX, RID_XANDY, RID_XORY,
      62             : };
      63             : 
      64             : const sal_uInt16 SmElementsControl::aRelationsList[] =
      65             : {
      66             :     RID_XEQY, RID_XNEQY, RID_XLTY, RID_XLEY,
      67             :     RID_XLESLANTY, RID_XGTY, RID_XGEY, RID_XGESLANTY,
      68             :     0xFFFF,
      69             :     RID_XAPPROXY, RID_XSIMY, RID_XSIMEQY, RID_XEQUIVY,
      70             :     RID_XPROPY, RID_XPARALLELY, RID_XORTHOY, RID_XDIVIDESY,
      71             :     RID_XNDIVIDESY, RID_XTOWARDY,
      72             :     0xFFFF,
      73             :     RID_DLARROW, RID_DLRARROW, RID_DRARROW,
      74             :     0xFFFF,
      75             :     RID_XPRECEDESY, RID_XSUCCEEDSY, RID_XPRECEDESEQUALY, RID_XSUCCEEDSEQUALY,
      76             :     RID_XPRECEDESEQUIVY, RID_XSUCCEEDSEQUIVY, RID_XNOTPRECEDESY, RID_XNOTSUCCEEDSY
      77             : };
      78             : 
      79             : const sal_uInt16 SmElementsControl::aSetOperations[] =
      80             : {
      81             :     RID_XINY, RID_XNOTINY, RID_XOWNSY,
      82             :     0xFFFF,
      83             :     RID_XINTERSECTIONY, RID_XUNIONY, RID_XSETMINUSY, RID_XSLASHY,
      84             :     RID_XSUBSETY, RID_XSUBSETEQY, RID_XSUPSETEQY, RID_XNSUBSETY,
      85             :     RID_XNSUBSETEQY, RID_XNSUPSETY, RID_XNSUPSETEQY,
      86             :     0xFFFF,
      87             :     RID_EMPTYSET, RID_ALEPH, RID_SETN, RID_SETZ,
      88             :     RID_SETQ, RID_SETR, RID_SETC
      89             : };
      90             : 
      91             : const sal_uInt16 SmElementsControl::aFunctions[] =
      92             : {
      93             :     RID_ABSX, RID_FACTX, RID_SQRTX, RID_NROOTXY,
      94             :     RID_RSUPX, RID_EX, RID_LNX, RID_EXPX,
      95             :     RID_LOGX,
      96             :     0xFFFF,
      97             :     RID_SINX, RID_COSX, RID_TANX, RID_COTX,
      98             :     RID_SINHX, RID_COSHX, RID_TANHX, RID_COTHX,
      99             :     0xFFFF,
     100             :     RID_ARCSINX, RID_ARCCOSX, RID_ARCTANX, RID_ARCCOTX,
     101             :     RID_ARSINHX, RID_ARCOSHX, RID_ARTANHX, RID_ARCOTHX
     102             : };
     103             : 
     104             : const sal_uInt16 SmElementsControl::aOperators[] =
     105             : {
     106             :     RID_LIMX, RID_SUMX, RID_PRODX, RID_COPRODX,
     107             :     RID_INTX, RID_IINTX, RID_IIINTX, RID_LINTX,
     108             :     RID_LLINTX, RID_LLLINTX,
     109             :     0xFFFF,
     110             :     RID_LIM_FROMX, RID_SUM_FROMX, RID_PROD_FROMX, RID_COPROD_FROMX,
     111             :     RID_INT_FROMX, RID_IINT_FROMX, RID_IIINT_FROMX, RID_LINT_FROMX,
     112             :     RID_LLINT_FROMX, RID_LLLINT_FROMX,
     113             :     0xFFFF,
     114             :     RID_LIM_TOX, RID_SUM_TOX, RID_PROD_TOX, RID_COPROD_TOX,
     115             :     RID_INT_TOX, RID_IINT_TOX, RID_IIINT_TOX, RID_LINT_TOX,
     116             :     RID_LLINT_TOX, RID_LLLINT_TOX,
     117             :     0xFFFF,
     118             :     RID_LIM_FROMTOX, RID_SUM_FROMTOX, RID_PROD_FROMTOX, RID_COPROD_FROMTOX,
     119             :     RID_INT_FROMTOX, RID_IINT_FROMTOX, RID_IIINT_FROMTOX, RID_LINT_FROMTOX,
     120             :     RID_LLINT_FROMTOX, RID_LLLINT_FROMTOX,
     121             : 
     122             : };
     123             : 
     124             : const sal_uInt16 SmElementsControl::aAttributes[] =
     125             : {
     126             :     RID_ACUTEX, RID_GRAVEX, RID_BREVEX, RID_CIRCLEX,
     127             :     RID_DOTX, RID_DDOTX, RID_DDDOTX, RID_BARX,
     128             :     RID_VECX, RID_TILDEX, RID_HATX,
     129             :     0xFFFF,
     130             :     RID_WIDEVECX, RID_WIDETILDEX, RID_WIDEHATX, RID_OVERLINEX,
     131             :     RID_UNDERLINEX, RID_OVERSTRIKEX,
     132             :     0xFFFF,
     133             :     RID_PHANTOMX, RID_BOLDX, RID_ITALX, RID_SIZEXY, RID_FONTXY
     134             : };
     135             : 
     136             : const sal_uInt16 SmElementsControl::aBrackets[] =
     137             : {
     138             :     RID_LRGROUPX,
     139             :     0xFFFF,
     140             :     RID_LRPARENTX, RID_LRBRACKETX, RID_LRDBRACKETX, RID_LRBRACEX,
     141             :     RID_LRANGLEX, RID_LMRANGLEXY, RID_LRCEILX, RID_LRFLOORX,
     142             :     RID_LRLINEX, RID_LRDLINEX,
     143             :     0xFFFF,
     144             :     RID_SLRPARENTX, RID_SLRBRACKETX, RID_SLRDBRACKETX, RID_SLRANGLEX,
     145             :     RID_SLMRANGLEXY, RID_SLRCEILX, RID_SLRFLOORX, RID_SLRLINEX,
     146             :     RID_SLRDLINEX,
     147             :     0XFFFF,
     148             :     RID_XOVERBRACEY, RID_XUNDERBRACEY
     149             : };
     150             : 
     151             : const sal_uInt16 SmElementsControl::aFormats[] =
     152             : {
     153             :     RID_RSUPX, RID_RSUBX, RID_LSUPX, RID_LSUBX,
     154             :     RID_CSUPX, RID_CSUBX,
     155             :     0xFFFF,
     156             :     RID_NEWLINE, RID_SBLANK, RID_BLANK, RID_NOSPACE,
     157             :     RID_BINOMXY, RID_STACK, RID_MATRIX,
     158             : };
     159             : 
     160             : const sal_uInt16 SmElementsControl::aOthers[] =
     161             : {
     162             :     RID_INFINITY, RID_PARTIAL, RID_NABLA, RID_EXISTS,
     163             :     RID_NOTEXISTS, RID_FORALL, RID_HBAR, RID_LAMBDABAR,
     164             :     RID_RE, RID_IM, RID_WP,
     165             :     0xFFFF,
     166             :     RID_LEFTARROW, RID_RIGHTARROW, RID_UPARROW, RID_DOWNARROW,
     167             :     0xFFFF,
     168             :     RID_DOTSLOW, RID_DOTSAXIS, RID_DOTSVERT, RID_DOTSUP,
     169             :     RID_DOTSDOWN
     170             : };
     171             : 
     172          17 : SmElementsControl::SmElementsControl(Window *pParent, const ResId& rResId) :
     173             :     Control(pParent, rResId),
     174          17 :     mpDocShell(new SmDocShell(SFXOBJECTSHELL_STD_NORMAL)),
     175             :     mpCurrentElement(NULL),
     176          34 :     mbVerticalMode(true)
     177             : {
     178          17 :     maFormat.SetBaseSize(PixelToLogic(Size(0, 24)));
     179          17 : }
     180             : 
     181          34 : void SmElementsControl::setVerticalMode(bool bVerticalMode)
     182             : {
     183          34 :     mbVerticalMode = bVerticalMode;
     184          34 : }
     185             : 
     186          13 : void SmElementsControl::Paint(const Rectangle&)
     187             : {
     188          13 :     Push();
     189             : 
     190          13 :     SetMapMode( MapMode(MAP_100TH_MM) );
     191          13 :     SetDrawMode( DRAWMODE_DEFAULT );
     192          13 :     SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
     193          13 :     SetDigitLanguage( LANGUAGE_ENGLISH );
     194             : 
     195          13 :     sal_Int32 boxX = maMaxElementDimensions.Width()  + 10;
     196          13 :     sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
     197             : 
     198          13 :     sal_Int32 x = 0;
     199          13 :     sal_Int32 y = 0;
     200             : 
     201          13 :     sal_Int32 perLine = 0;
     202             : 
     203          13 :     if (mbVerticalMode)
     204           0 :         perLine = GetOutputSizePixel().Height() / boxY;
     205             :     else
     206          13 :         perLine = GetOutputSizePixel().Width()  / boxX;
     207             : 
     208          13 :     if(perLine <= 0) {
     209           0 :         perLine = 1;
     210             :     }
     211             : 
     212          13 :     if (mbVerticalMode)
     213           0 :         boxY = GetOutputSizePixel().Height() / perLine;
     214             :     else
     215          13 :         boxX = GetOutputSizePixel().Width() / perLine;
     216             : 
     217         273 :     for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
     218             :     {
     219         260 :         SmElement* element = maElementList[i].get();
     220         260 :         if (element->isSeparator())
     221             :         {
     222          26 :             if (mbVerticalMode)
     223             :             {
     224           0 :                 x += boxX;
     225           0 :                 y = 0;
     226             : 
     227             :                 Rectangle aSelectionRectangle(
     228             :                     x+5-1, y+5,
     229           0 :                     x+5+1, GetOutputSizePixel().Height() - 5);
     230             : 
     231           0 :                 DrawRect(PixelToLogic(aSelectionRectangle));
     232           0 :                 x += 10;
     233             :             }
     234             :             else
     235             :             {
     236          26 :                 x = 0;
     237          26 :                 y += boxY;
     238             : 
     239             :                 Rectangle aSelectionRectangle(
     240             :                     x+5,                              y+5-1,
     241          26 :                     GetOutputSizePixel().Width() - 5, y+5+1);
     242             : 
     243          26 :                 DrawRect(PixelToLogic(aSelectionRectangle));
     244          26 :                 y += 10;
     245             :             }
     246             :         }
     247             :         else
     248             :         {
     249         234 :             Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight()));
     250         234 :             if(mbVerticalMode)
     251             :             {
     252           0 :                 if ( y + boxY > GetOutputSizePixel().Height())
     253             :                 {
     254           0 :                     x += boxX;
     255           0 :                     y = 0;
     256             :                 }
     257             :             }
     258             :             else
     259             :             {
     260         234 :                 if ( x + boxX > GetOutputSizePixel().Width())
     261             :                 {
     262          26 :                     x = 0;
     263          26 :                     y += boxY;
     264             :                 }
     265             :             }
     266             : 
     267         234 :             if (mpCurrentElement == element)
     268             :             {
     269           0 :                 Push();
     270           0 :                 SetFillColor( Color(230, 230, 230) );
     271           0 :                 SetLineColor( Color(230, 230, 230) );
     272             : 
     273           0 :                 DrawRect(PixelToLogic(Rectangle(x+2, y+2, x+boxX-2, y+boxY-2)));
     274           0 :                 Pop();
     275             :             }
     276             : 
     277         234 :             Point location(x + ((boxX-aSizePixel.Width())/2), y + ((boxY-aSizePixel.Height())/2));
     278         234 :             SmDrawingVisitor(*this, PixelToLogic(location), element->getNode().get());
     279             : 
     280         234 :             element->mBoxLocation = Point(x,y);
     281         234 :             element->mBoxSize     = Size(boxX, boxY);
     282             : 
     283         234 :             if(mbVerticalMode)
     284           0 :                 y += boxY;
     285             :             else
     286         234 :                 x += boxX;
     287             :         }
     288             :     }
     289             : 
     290          13 :     Pop();
     291          13 : }
     292             : 
     293           0 : void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
     294             : {
     295           0 :     mpCurrentElement = NULL;
     296           0 :     if (Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()))
     297             :     {
     298           0 :         for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
     299             :         {
     300           0 :             SmElement* element = maElementList[i].get();
     301           0 :             Rectangle rect(element->mBoxLocation, element->mBoxSize);
     302           0 :             if (rect.IsInside(rMouseEvent.GetPosPixel()))
     303             :             {
     304           0 :                 if (mpCurrentElement != element)
     305             :                 {
     306           0 :                     mpCurrentElement = element;
     307           0 :                     Invalidate();
     308             :                 }
     309             :             }
     310             :         }
     311             :     }
     312             :     else
     313             :     {
     314           0 :         Control::MouseMove (rMouseEvent);
     315             :     }
     316           0 : }
     317             : 
     318           0 : void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
     319             : {
     320           0 :     GrabFocus();
     321             : 
     322           0 :     if (rMouseEvent.IsLeft() && Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()))
     323             :     {
     324           0 :         for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
     325             :         {
     326           0 :             SmElement* element = maElementList[i].get();
     327           0 :             Rectangle rect(element->mBoxLocation, element->mBoxSize);
     328           0 :             if (rect.IsInside(rMouseEvent.GetPosPixel()))
     329             :             {
     330           0 :                 aSelectHdlLink.Call(element);
     331           0 :                 return;
     332             :             }
     333             :         }
     334             :     }
     335             :     else
     336             :     {
     337           0 :         Control::MouseButtonDown (rMouseEvent);
     338             :     }
     339             : }
     340             : 
     341          34 : void SmElementsControl::addSeparator()
     342             : {
     343          34 :     SmElementPointer pElement(new SmElementSeparator());
     344          34 :     maElementList.push_back(pElement);
     345          34 : }
     346             : 
     347         306 : void SmElementsControl::addElement(OUString aElementVisual, OUString aElementSource)
     348             : {
     349         306 :     SmNodePointer pNode(SmParser().ParseExpression(aElementVisual));
     350             : 
     351         306 :     pNode->Prepare(maFormat, *mpDocShell);
     352         306 :     pNode->SetSize(Fraction(10,8));
     353         306 :     pNode->Arrange(*this, maFormat);
     354             : 
     355         306 :     Size aSizePixel = LogicToPixel(Size(pNode->GetWidth(), pNode->GetHeight()), MAP_100TH_MM);
     356         306 :     if (aSizePixel.Width() > maMaxElementDimensions.Width()) {
     357          68 :         maMaxElementDimensions.Width() = aSizePixel.Width();
     358             :     }
     359             : 
     360         306 :     if (aSizePixel.Height() > maMaxElementDimensions.Height()) {
     361          34 :         maMaxElementDimensions.Height() = aSizePixel.Height();
     362             :     }
     363             : 
     364         612 :     SmElementPointer pElement(new SmElement(pNode, aElementSource));
     365         612 :     maElementList.push_back(pElement);
     366         306 : }
     367             : 
     368          17 : void SmElementsControl::setElementSetId(sal_uInt16 aSetId)
     369             : {
     370          17 :     maCurrentSetId = aSetId;
     371          17 :     maMaxElementDimensions = Size();
     372          17 :     build();
     373          17 : }
     374             : 
     375          17 : void SmElementsControl::addElements(const sal_uInt16 aElementsArray[], sal_uInt16 aElementsArraySize)
     376             : {
     377         357 :     for (sal_uInt16 i = 0; i < aElementsArraySize ; i++)
     378             :     {
     379         340 :         sal_uInt16 aElementId = aElementsArray[i];
     380         340 :         if (aElementId == 0xFFFF) {
     381          34 :             addSeparator();
     382             :         } else {
     383         306 :             if (aElementId == RID_NEWLINE)
     384           0 :                 addElement(OStringToOUString( "\xe2\x86\xb5", RTL_TEXTENCODING_UTF8 ), SmResId(aElementId));
     385         306 :             else if (aElementId == RID_SBLANK)
     386           0 :                 addElement(OUString("\"`\""), SmResId(aElementId));
     387         306 :             else if (aElementId == RID_BLANK)
     388           0 :                 addElement(OUString("\"~\""), SmResId(aElementId));
     389         306 :             else if (aElementId == RID_PHANTOMX)
     390           0 :                 addElement(OUString("\"hide\""), SmResId(aElementId));
     391         306 :             else if (aElementId == RID_BOLDX)
     392           0 :                 addElement(OUString("bold B"), SmResId(aElementId));
     393         306 :             else if (aElementId == RID_ITALX)
     394           0 :                 addElement(OUString("ital I"), SmResId(aElementId));
     395         306 :             else if (aElementId == RID_SIZEXY)
     396           0 :                 addElement(OUString("\"size\""), SmResId(aElementId));
     397         306 :             else if (aElementId == RID_FONTXY)
     398           0 :                 addElement(OUString("\"font\""), SmResId(aElementId));
     399             :             else
     400         306 :                 addElement(SmResId(aElementId), SmResId(aElementId));
     401             :         }
     402             :     }
     403          17 : }
     404             : 
     405          17 : void SmElementsControl::build()
     406             : {
     407          17 :     maElementList.clear();
     408             : 
     409          17 :     switch(maCurrentSetId)
     410             :     {
     411             :         case RID_CATEGORY_UNARY_BINARY_OPERATORS:
     412          17 :             addElements(aUnaryBinaryOperatorsList, sizeof(aUnaryBinaryOperatorsList) / sizeof(sal_uInt16));
     413          17 :         break;
     414             :         case RID_CATEGORY_RELATIONS:
     415           0 :             addElements(aRelationsList, sizeof(aRelationsList) / sizeof(sal_uInt16));
     416           0 :         break;
     417             :         case RID_CATEGORY_SET_OPERATIONS:
     418           0 :             addElements(aSetOperations, sizeof(aSetOperations) / sizeof(sal_uInt16));
     419           0 :         break;
     420             :         case RID_CATEGORY_FUNCTIONS:
     421           0 :             addElements(aFunctions, sizeof(aFunctions) / sizeof(sal_uInt16));
     422           0 :         break;
     423             :         case RID_CATEGORY_OPERATORS:
     424           0 :             addElements(aOperators, sizeof(aOperators) / sizeof(sal_uInt16));
     425           0 :         break;
     426             :         case RID_CATEGORY_ATTRIBUTES:
     427           0 :             addElements(aAttributes, sizeof(aAttributes) / sizeof(sal_uInt16));
     428           0 :         break;
     429             :         case RID_CATEGORY_BRACKETS:
     430           0 :             addElements(aBrackets, sizeof(aBrackets) / sizeof(sal_uInt16));
     431           0 :         break;
     432             :         case RID_CATEGORY_FORMATS:
     433           0 :             addElements(aFormats, sizeof(aFormats) / sizeof(sal_uInt16));
     434           0 :         break;
     435             :         case RID_CATEGORY_OTHERS:
     436           0 :             addElements(aOthers, sizeof(aOthers) / sizeof(sal_uInt16));
     437           0 :         break;
     438             :         case RID_CATEGORY_EXAMPLES:
     439             :         {
     440           0 :             OUString aEquation = OUString("C=%pi cdot d = 2 cdot %pi cdot r");
     441           0 :             addElement(aEquation, aEquation);
     442           0 :             aEquation = OUString("E=mc^2");
     443           0 :             addElement(aEquation, aEquation);
     444           0 :             aEquation = OUString("a^2 + b^2 = c^2");
     445           0 :             addElement(aEquation, aEquation);
     446           0 :             aEquation = OUString("f ( x ) = sum from { { i = 0 } } to { infinity } { {f^{(i)}(0)} over {i!} x^i}");
     447           0 :             addElement(aEquation, aEquation);
     448           0 :             aEquation = OUString("f ( x ) = {1} over {%sigma sqrt{2%pi} }e^-{{(x-%mu)^2} over {2%sigma^2}}");
     449           0 :             addElement(aEquation, aEquation);
     450             :         }
     451           0 :         break;
     452             :     }
     453          17 :     Invalidate();
     454          17 : }
     455             : 
     456             : //*******************
     457             : 
     458             : const sal_uInt16 SmElementsDockingWindow::aCategories[] = {
     459             :     RID_CATEGORY_UNARY_BINARY_OPERATORS,
     460             :     RID_CATEGORY_RELATIONS,
     461             :     RID_CATEGORY_SET_OPERATIONS,
     462             :     RID_CATEGORY_FUNCTIONS,
     463             :     RID_CATEGORY_OPERATORS,
     464             :     RID_CATEGORY_ATTRIBUTES,
     465             :     RID_CATEGORY_BRACKETS,
     466             :     RID_CATEGORY_FORMATS,
     467             :     RID_CATEGORY_OTHERS,
     468             :     RID_CATEGORY_EXAMPLES
     469             : };
     470             : 
     471          17 : SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, SfxChildWindow* pChildWindow, Window* pParent) :
     472             :     SfxDockingWindow(pInputBindings, pChildWindow, pParent, SmResId(RID_ELEMENTSDOCKINGWINDOW)),
     473             :     maElementsControl   (this, SmResId(1)),
     474          17 :     maElementListBox    (this, SmResId(1))
     475             : {
     476          17 :     maElementsControl.SetBorderStyle( WINDOW_BORDER_MONO );
     477             : 
     478          17 :     maElementListBox.SetDropDownLineCount( 10 );
     479             : 
     480         187 :     for (sal_uInt16 i = 0; i < sizeof(aCategories) / sizeof(sal_uInt16) ; i++)
     481             :     {
     482         170 :         maElementListBox.InsertEntry(OUString(SmResId(aCategories[i])));
     483             :     }
     484             : 
     485          17 :     maElementListBox.SetSelectHdl(LINK(this, SmElementsDockingWindow, ElementSelectedHandle));
     486             : 
     487          17 :     Wallpaper aWallpaper( Color( COL_WHITE ) );
     488             : 
     489          17 :     maElementsControl.SetBackground( aWallpaper );
     490          17 :     maElementsControl.SetTextColor( Color( COL_BLACK ) );
     491          17 :     maElementsControl.SetSelectHdl(LINK(this, SmElementsDockingWindow, SelectClickHdl));
     492             : 
     493          17 :     maElementListBox.SelectEntry(OUString(SmResId(RID_CATEGORY_UNARY_BINARY_OPERATORS)));
     494          17 :     maElementsControl.setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS);
     495             : 
     496          17 :     FreeResource();
     497          17 : }
     498             : 
     499          34 : SmElementsDockingWindow::~SmElementsDockingWindow ()
     500             : {
     501          34 : }
     502             : 
     503           0 : void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode)
     504             : {
     505           0 :     SfxDockingWindow::EndDocking(rReactangle, bFloatMode);
     506           0 :     bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM );
     507           0 :     maElementsControl.setVerticalMode(bVertical);
     508           0 : }
     509             : 
     510           0 : IMPL_LINK( SmElementsDockingWindow, SelectClickHdl, SmElement*, pElement)
     511             : {
     512           0 :     SmViewShell* pViewSh = GetView();
     513             : 
     514           0 :     if (pViewSh)
     515             :     {
     516             :         pViewSh->GetViewFrame()->GetDispatcher()->Execute(
     517             :             SID_INSERTCOMMANDTEXT, SFX_CALLMODE_STANDARD,
     518           0 :             new SfxStringItem(SID_INSERTCOMMANDTEXT, pElement->getText()), 0L);
     519             :     }
     520           0 :     return 0;
     521             : }
     522             : 
     523           0 : IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, ListBox*, pList)
     524             : {
     525           0 :     for (sal_uInt16 i = 0; i < sizeof(aCategories) / sizeof(sal_uInt16) ; i++)
     526             :     {
     527           0 :         sal_uInt16 aCurrentCategory = aCategories[i];
     528           0 :         OUString aCurrentCategoryString = OUString(SmResId(aCurrentCategory));
     529           0 :         if (aCurrentCategoryString == pList->GetSelectEntry())
     530             :         {
     531           0 :             maElementsControl.setElementSetId(aCurrentCategory);
     532           0 :             return 0;
     533             :         }
     534           0 :     }
     535           0 :     return 0;
     536             : }
     537             : 
     538           0 : SmViewShell* SmElementsDockingWindow::GetView()
     539             : {
     540           0 :     SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell();
     541           0 :     return PTR_CAST(SmViewShell, pView);
     542             : }
     543             : 
     544          34 : void SmElementsDockingWindow::Resize()
     545             : {
     546          34 :     bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM );
     547          34 :     maElementsControl.setVerticalMode(bVertical);
     548             : 
     549          34 :     sal_uInt32 aWidth  = GetOutputSizePixel().Width();
     550          34 :     sal_uInt32 aHeight = GetOutputSizePixel().Height();
     551             : 
     552          34 :     sal_uInt32 aElementsSetsHeight = 23;
     553          34 :     sal_uInt32 aPadding = 5;
     554             : 
     555          34 :     Rectangle aRect1 = Rectangle(aPadding, aPadding, aWidth - aPadding, aElementsSetsHeight + aPadding);
     556             : 
     557          34 :     maElementListBox.SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize());
     558             : 
     559          34 :     Rectangle aRect = Rectangle(aPadding, aElementsSetsHeight + aPadding + aPadding, aWidth - aPadding, aHeight - aPadding);
     560             : 
     561          34 :     maElementsControl.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize());
     562             : 
     563          34 :     SfxDockingWindow::Resize();
     564          34 :     Invalidate();
     565          34 : }
     566             : 
     567          48 : SFX_IMPL_DOCKINGWINDOW_WITHID(SmElementsDockingWindowWrapper, SID_ELEMENTSDOCKINGWINDOW);
     568             : 
     569          17 : SmElementsDockingWindowWrapper::SmElementsDockingWindowWrapper(
     570             :                             Window *pParentWindow, sal_uInt16 nId,
     571             :                             SfxBindings *pBindings, SfxChildWinInfo *pInfo) :
     572          17 :     SfxChildWindow(pParentWindow, nId)
     573             : {
     574          17 :     pWindow = new SmElementsDockingWindow(pBindings, this, pParentWindow);
     575          17 :     SmElementsDockingWindow* pDialog = (SmElementsDockingWindow*) pWindow;
     576          17 :     pDialog->SetPosSizePixel(Point(0, 0), Size(300, 0));
     577          17 :     pDialog->Show();
     578             : 
     579          17 :     eChildAlignment = SFX_ALIGN_LEFT;
     580             : 
     581          17 :     pDialog->Initialize( pInfo );
     582          17 : }
     583             : 
     584          34 : SmElementsDockingWindowWrapper::~SmElementsDockingWindowWrapper()
     585             : {
     586          55 : }
     587             : 
     588             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10