bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / source / dialog / dialoghelper.cxx
blobe60edb12ba310cfdd37ea0b71596564ca1a85056
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <sfx2/dialoghelper.hxx>
11 #include <tools/datetime.hxx>
12 #include <vcl/builder.hxx>
13 #include <vcl/layout.hxx>
14 #include <vcl/settings.hxx>
15 #include <vector>
17 //these tab pages both have the same basic layout with a preview on the
18 //right, get both of their non-preview areas to request the same size
19 //so that the preview appears in the same place in each one so
20 //flipping between tabs isn't distracting as it jumps around
21 void setPreviewsToSamePlace(vcl::Window *pParent, VclBuilderContainer *pPage)
23 vcl::Window *pOurGrid = pPage->get<vcl::Window>("maingrid");
24 if (!pOurGrid)
25 return;
27 std::vector<vcl::Window*> aGrids;
28 aGrids.push_back(pOurGrid);
30 for (vcl::Window* pChild = pParent->GetWindow(GetWindowType::FirstChild); pChild;
31 pChild = pChild->GetWindow(GetWindowType::Next))
33 VclBuilderContainer *pPeer = dynamic_cast<VclBuilderContainer*>(pChild);
34 if (!pPeer || pPeer == pPage || !pPeer->hasBuilder())
35 continue;
37 vcl::Window *pOtherGrid = pPeer->get<vcl::Window>("maingrid");
38 if (!pOtherGrid)
39 continue;
41 aGrids.push_back(pOtherGrid);
44 if (aGrids.size() > 1)
46 std::shared_ptr<VclSizeGroup> xGroup(std::make_shared<VclSizeGroup>());
47 for (std::vector<vcl::Window*>::iterator aI = aGrids.begin(); aI != aGrids.end(); ++aI)
49 vcl::Window *pWindow = *aI;
50 pWindow->remove_from_all_size_groups();
51 pWindow->add_to_size_group(xGroup);
56 Size getParagraphPreviewOptimalSize(const vcl::Window *pReference)
58 return pReference->LogicToPixel(Size(68 , 112), MAP_APPFONT);
61 Size getDrawPreviewOptimalSize(const vcl::Window *pReference)
63 return pReference->LogicToPixel(Size(88, 42), MAP_APPFONT);
66 Size getDrawListBoxOptimalSize(const vcl::Window *pReference)
68 return pReference->LogicToPixel(Size(88, 110), MAP_APPFONT);
71 Size getPreviewStripSize(const vcl::Window *pReference)
73 return pReference->LogicToPixel(Size(70 , 40), MapMode(MAP_APPFONT));
76 Size getPreviewOptionsSize(const vcl::Window *pReference)
78 return pReference->LogicToPixel(Size(70 , 27), MapMode(MAP_APPFONT));
81 OUString getWidestTime(const LocaleDataWrapper& rWrapper)
83 Date aDate(22, 12, 2000);
84 tools::Time aTime(22, 59, 59);
85 DateTime aDateTime(aDate, aTime);
86 return formatTime(aDateTime, rWrapper);
89 OUString formatTime(const DateTime& rDateTime, const LocaleDataWrapper& rWrapper)
91 OUString sString = rWrapper.getDate(rDateTime);
92 sString += OUString(' ');
93 sString += rWrapper.getTime(rDateTime, false);
94 return sString;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */